package com.acwing.chacter1;

import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 * @author anan
 * @create 2021-07-21 18:57
 */
public class QuickSort {

    public static void quickSort(int[] arr, int l, int r){
        if (l >= r){
            return;
        }
        int x = arr[l + r >> 1];
        int i = l - 1;
        int j = r + 1;
        while (i < j){
            do i++; while (arr[i] < x);
            do j--; while (arr[j] > x);
            if (i < j){
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
                }
        }
        quickSort(arr, l, j);
        quickSort(arr, j+1, r);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        Integer n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }

        quickSort(arr, 0, n - 1);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }


    }
}
